<?php
$oUsers = UserHandler::getUsers();
$bAdmin = $oUsers[$_SESSION['rid']]->bAdmin;
$sColspan = ($bAdmin ? '7' : '6');
?>
<table class="boxborder" cellspacing="0">
	<tr>
		<td class="boxhandle" colspan="<?php print $sColspan ?>"><?php print msg('Users') ?> (<?php print count($oUsers) ?>)</td>
	</tr>
	<tr>
		<td class="control small" colspan="<?php print $sColspan ?>">
			<?php print msg('Users') ?> | <a href="index.php?sView=usergroup-list"><?php print msg('Usergroups') ?></a> |
		</td>
	</tr>
	<tr>
	<?php
	if (USER_MANAGEMENT === true)
	{
		?>
		<td class="listtop center">
		<?php
		if ($bAdmin) {
			echo '<a href="javascript: showBox(\'user-add\');"><img src="images/'.$_SESSION['oUserVars']['images'].'/user-add.png" border="0"></a>';
		}
		else {
			echo '&nbsp;';
		}
		?>
		</td>
		<?php
	}
	?>
		<td class="listtop nowrap"><?php print msg('Username') ?></td>
		<td class="listtop nowrap"><?php print msg('Full name') ?></td>
		<td class="listtop nowrap"><?php print msg('E-mail') ?></td>
		<td class="listtop nowrap center"><?php print msg('Admin') ?></td>
		<td class="listtop nowrap center"><?php print msg('Accountant') ?></td>
	<?php
	if ($bAdmin) {
		echo '<td class="listtop center">'.msg('Login').'</td>';
	}
	?>
	</tr>
<?php
foreach ($oUsers as $oThisUser) {
	?>
	<tr>
	<?php
	if (USER_MANAGEMENT === true) {
		?>
		<td class="listentity center" nowrap>
		<?php
		if ($bAdmin) {
			if ($oThisUser->iID != $_SESSION['rid']) {
				print '<a href="javascript: showBox(\'user-delete\', \'iUser='.$oThisUser->iID.'\');"><img src="images/'.$_SESSION['oUserVars']['images'].'/user-delete.png" border="0"></a> ';
			}
			print '<a href="javascript: showBox(\'user-change\', \'iUser='.$oThisUser->iID.'\');"><img src="images/'.$_SESSION['oUserVars']['images'].'/user-change.png" border="0"></a>';
		}
		else if ($oThisUser->iID == $_SESSION['rid']) {
			print '<a href="javascript: showBox(\'user-change\', \'iUser='.$oThisUser->iID.'\');"><img src="images/'.$_SESSION['oUserVars']['images'].'/user-change.png" border="0"></a>';
		}
		else {
			print '&nbsp;';
		}
		?>
		</td>
		<?php
	}
	?>
		<td class="listentity">
	<?php
	if ($oThisUser->iID == $_SESSION['rid'])
		echo '<a href="index.php?sView=user-view&iUser='.$oThisUser->iID.'"><b>'.$oThisUser->sUser.'</b></a>';
	else
		echo '<a href="index.php?sView=user-view&iUser='.$oThisUser->iID.'">'.$oThisUser->sUser.'</a>';
	?>
		</td>
		<td class="listentity nowrap"><?php print $oThisUser->sFullname ?>&nbsp;</td>
		<td class="listentity"><a href="mailto: <?php print $oThisUser->sEmail ?>"><?php print $oThisUser->sEmail ?></a>&nbsp;</td>
		<td class="listentity center"><?php print ($oThisUser->bAdmin ? msg('Yes') : msg('No')) ?></td>
		<td class="listentity center"><?php print ($oThisUser->bAccountant ? msg('Yes') : msg('No')) ?></td>
	<?php
	if ($bAdmin)
		echo '<td class="listentity center" nowrap>'.coolDate($oThisUser->iLastlogon).'&nbsp;</td>';
	?>
	</tr>
	<?php
}
?>
</table>
